package com.example.demo.bean;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

@Data
public class PageFlow implements Serializable {
    private List<NodeData> nodeDataArray;
    private List<LinkData> linkDataArray;

    @JsonIgnore
    public String getNodeDataArrayJsonStr(){
    return new Gson().toJson(this.getNodeDataArray());
    }
    @JsonIgnore
    public String getLinkDataArrayJsonStr(){
        return new Gson().toJson(this.getLinkDataArray());
    }
    @Data
    public static class NodeData implements Serializable{
        public NodeData() {
        }

        public NodeData(Integer key, String text, String category, String color, List<Reasons> reasonsLists) {
            this.key = key;
            this.text = text;
            this.category = category;
            this.color = color;
            this.reasonsLists = reasonsLists;
        }

        @SerializedName("key")
        @JsonInclude(JsonInclude.Include.NON_NULL)
        private Integer key;

        @SerializedName("text")
        @JsonInclude(JsonInclude.Include.NON_NULL)
        private String text;

        @SerializedName("category")
        @JsonInclude(JsonInclude.Include.NON_NULL)
        private String category;

        @SerializedName("color")
        @JsonInclude(JsonInclude.Include.NON_NULL)
        private String color;

        @JsonInclude(JsonInclude.Include.NON_EMPTY)
        private List<Reasons> reasonsLists;
    }

    @Data
    public static class LinkData implements Serializable{
        public LinkData() {
        }

        public LinkData(Integer from, Integer to) {
            this.from = from;
            this.to = to;
        }

        @SerializedName("from")
        @JsonInclude(JsonInclude.Include.NON_NULL)
        private Integer from;

        @SerializedName("to")
        @JsonInclude(JsonInclude.Include.NON_NULL)
        private Integer to;

        @SerializedName("category")
        @JsonInclude(JsonInclude.Include.NON_NULL)
        private String category ="dashed";

    }

    @Data
    public static class Reasons implements Serializable{
        @SerializedName("text")
        @JsonInclude(JsonInclude.Include.NON_NULL)
        private String text;
    }
}